<template>
    <view>
        <view class="user_info_wrap">
            <view v-if="userinfo.avatarUrl" class="user_img_wrap">
                <image class="user_bg" :src="userinfo.avatarUrl"></image>
                <view class="user_info">
                    <image class="user_icon" :src="userinfo.avatarUrl"></image>
                    <view class="user_name">{{ userinfo.nickName }}</view>
                </view>
            </view>
            <view v-else class="user_btn">
                <navigator url="/pages/login/index">登录</navigator>
            </view>
        </view>

        <view class="user_content">
            <view class="user_main">
                <!-- 历史足迹  -->
                <view class="history_wrap">
                    <navigator>
                        <view class="his_num">0</view>
                        <view class="his name">收藏的店铺</view>
                    </navigator>
                    <navigator url="/pages/collect/index">
                        <view class="his_num">{{ collectNumber }}</view>
                        <view class="his name">收藏的商品</view>
                    </navigator>
                    <navigator>
                        <view class="his_num">0</view>
                        <view class="his name">关注的商品</view>
                    </navigator>
                    <navigator>
                        <view class="his_num">0</view>
                        <view class="his name">我的足迹</view>
                    </navigator>
                </view>
                <!-- 我的订单 -->
                <view class="order_wrap">
                    <view class="order_title">我的订单</view>
                    <view class="order_content">
                        <!-- 分包前 -->
                        <!-- <navigator url="/pages/order/index?type=1">
                   <view class="iconfont icon-dingdan1"></view>
                   <view class="order_name">全部订单</view>
               </navigator> -->

                        <!-- 分包后 -->
                        <navigator url="/packageA/order/index?type=1">
                            <view class="iconfont icon-dingdan1"></view>
                            <view class="order_name">全部订单</view>
                        </navigator>
                        <navigator url="/pages/order/index?type=2">
                            <view class="iconfont icon-fukuan"></view>
                            <view class="order_name">待付款</view>
                        </navigator>
                        <navigator url="/pages/order/index?type=3">
                            <view class="iconfont icon-wuliu"></view>
                            <view class="order_name">待收货</view>
                        </navigator>
                        <navigator>
                            <view class="iconfont icon-tuihuotuikuan-"></view>
                            <view class="order_name">退款/退货</view>
                        </navigator>
                    </view>
                </view>
                <!-- 收货地址管理 -->
                <view class="address_wrap">收货地址管理</view>

                <!-- 应用信息相关 -->
                <view class="app_info_wrap">
                    <view class="app_info_item app_info_cantact">
                        <text>联系客服</text>
                        <text>400-418-40000</text>
                    </view>
                    <!-- 未使用分包前 -->
                    <!-- <navigator url="/pages/feedback/index" class="address_wrap">意见反馈</navigator> -->

                    <!-- 使用分包后 -->
                    <navigator url="/packageA/feedback/index" class="address_wrap">意见反馈</navigator>
                    <view class="address_wrap">关于我们</view>
                </view>
                <view class="recommend_wrap">把应用推荐给其他人</view>
            </view>
        </view>
    </view>
</template>

<script>
// pages/user/index.js
export default {
    data() {
        return {
            userinfo: {
                avatarUrl: '',
                nickName: ''
            },
            collectNumber: 0
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad: function (options) {},
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        const userinfo = uni.getStorageSync('userinfo'); // console.log(userinfo)

        this.setData({
            userinfo
        });
        let collectNumber = uni.getStorageSync('collect').length;
        console.log(collectNumber);
        this.setData({
            collectNumber
        });
    },
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {},
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {},
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {},
    methods: {}
};
</script>
<style>
@import './index.css';
</style>
